<?php
session_start();

/*
	status	|	Error
	1		|	Error in query execution
	2		|	Error in connection
	3		|	Error in database selection
	4		|	Some session variable is unavailable
*/
if(session_id() != ''){
	if(!empty($_SESSION['username']) && !empty($_SESSION['password'])){
		
		$link = mysql_connect('localhost', $_SESSION['username'], $_SESSION['password']);
		if(!$link){
			echo 2;
		}else{
			if(mysql_select_db('greprep',$link)){
				$res = mysql_query('CALL initialize_data();', $link);
				
				if(!$res){
					echo 1;
				}else{
					echo 0;
				}
			}else{
				echo 3;
			}
		}
	}else{
		echo 4;
	}
}else{
	echo 4;
}		
?>
